how to calculate bitwise and